<template>
	<div class="main-content">
		<div class="screen-frame clearfix">
			<ul class="premises-details">
				<li class="col-sm-12 col-md-6">
					<div class="list-info-template">
						<div class="control-details">
							<input type="text" class="form-control" placeholder="楼盘名称" v-model="params.premisesName">
							<button class="btn btn-theme searchBtn" @click="dynamicList">搜索</button>
						</div>
					</div>
				</li>
			</ul>

		</div>
		<div class="table-responsive report-table">
			<table class="table table-striped table-bordered min-width-1060">
				<thead>
					<tr>
						<th width="20%">楼盘名称</th>
						<th width="40%">楼盘动态</th>
						<th width="15%">更新时间</th>
						<th width="10%">是否显示</th>
						<th width="30%">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr v-for="(row, index) in pageList">
						<td>{{row.premisesName}}</td>
						<td class="dynamic" style="text-align: left;">{{row.title}}</td>
						<td>{{(row.updateTime!=null)?row.updateTime:row.createTime}}</td>
						<td>{{row.canSeeName}}</td>
						<td><a @click="toDynamicDetail(row.id)" class="btnA edit">查看详情</a></td>
					</tr>
				</tbody>
			</table>
		</div>
		<div id="laypage_div"></div>
	</div>
</template>

<script>
	export default {
		name: 'dynamic',
		data() {
			return {
				params: {
					pageSize: 10,
					pageNo: 1,
					premisesName: ''
				},
				pageList: []
			}
		},
		components: {},
		mounted: function() {
			this.dynamicList();
		},
		methods: {
			dynamicList() {
				var _self = this;
				var body = {};
				body.params = _self.params;
				var url = _self.utilHelper.apiUrl + "/api/getAgentPremisesDynamicPage";
				this.$http.post(url,body).then((response) => {
					var res = response.body.resData.page;
					var rows = res.rows;
					_self.pageList = rows;
					var totalPages = res.totalPages;

					//加载分页组件
					laypage({
						cont: $('#laypage_div'), //容器。值支持id名、原生dom对象，jquery对象,
						pages: totalPages, //总页数
						curr: _self.params.pageNo,
						skip: true, //是否开启跳页
						skin: '#f87242',
						groups: 3, //连续显示分页数
						jump: function(obj, first) {
							if(!first) {
								_self.params.pageNo = obj.curr;
								_self.dynamicList();
							}
						}
					});
				}, (response) => {
					console.log(response);
				});
			},
			toDynamicDetail(id) {
				this.$router.replace({
					path: '/dynamicDetail/'+id
				})
			}
		}
	}
</script>